home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 December / macformat-057.iso / mac / Demos / Lineker's Real Football Demo / DATA / ScrlMenu / 00001_Script_1 next >
Encoding:
Text File  |  1997-08-03  |  6.7 KB  |  276 lines

  1. global current,hoff,hpos,hcol,msprite, fsprite
  2. global hspace,datecast,spriteorder
  3. global keydates, lasthl, cdvar, bigskip
  4. global currentmin, currentmax
  5.  
  6. on startmovie
  7.   setupdatevars
  8.   setupdummydates
  9. end startmovie
  10.  
  11.  
  12. on setupmenu
  13.   set fsprite = 63
  14.   set bigskip = 28
  15.   set datecast = the number of member "datecast"
  16.   set spriteorder =[0,1,2,3,4,5]
  17.   set current = 1
  18.   set currentmin = 1
  19.   set currentmax = 2557
  20.   repeat with j = 1 to 6
  21.     puppetsprite (fsprite+j),1
  22.     set the text of cast (datecast+(j-1)) = finddate (mygetat(keydates,current+(j-3)))
  23.     set the forecolor of member (datecast+(j-1)) = 0
  24.   end repeat
  25.   set lasthl = datecast+2
  26.   set the forecolor of member lasthl = 5
  27.   set hoff = 0
  28.   set hspace = 128
  29.   updatestage
  30. end setupmenu
  31.  
  32.  
  33. on redisplaydates
  34.   if cdvar then
  35.     repeat with j = 1 to 6
  36.       set the text of cast (datecast+getat(spriteorder,j)) =¨
  37. finddate (mygetat(keydates,current+(bigskip*(cdvar*(j-3)))))
  38.     end repeat
  39.   else
  40.     repeat with j = 1 to 6
  41.       set the text of cast (datecast+getat(spriteorder,j)) =¨
  42. finddate (mygetat(keydates,current+(j-3)))
  43.     end repeat
  44.   end if
  45.   updatestage
  46. end redisplaydates
  47.  
  48.  
  49.  
  50. ON scrolldates
  51.   if lasthl<>0 then
  52.     set the forecolor of member lasthl = 0
  53.     set lasthl = 0
  54.   end if
  55.   SET STEP = 20
  56.   SET RANGE = 100
  57.   SET baseH = THE MOUSEH
  58.   REPEAT WHILE THE stilldown
  59.     SET TMPH = THE MOUSEH
  60.     --    set the loch of sprite cursprite = tmph
  61.     --    set the locv of sprite cursprite = tmpv
  62.     set tmph = tmph-baseh
  63.     IF TMPH <>0 THEN
  64.       SET X = -TMPH/5
  65.       if x>48 then
  66.         set x = 48
  67.       else if x<-48 then
  68.         set x = -48
  69.       end if
  70.     END IF
  71.     if moveposs (x) then
  72.       displaydates x
  73.     end if
  74.   END REPEAT
  75.   updatestage
  76. END scrolldates
  77.  
  78. on mywait val
  79.   global lasttime
  80.   repeat while the ticks < lasttime+val
  81.   end repeat
  82.   set lasttime = the ticks
  83. end mywait
  84.  
  85. on findclosest
  86.   set sofar = 1000
  87.   repeat with j = 1 to 6
  88.     set dist = abs(320-(the loch of sprite (10+(j-1))+64))
  89.     if dist<=sofar then
  90.       set sofar = dist
  91.       set cnum = j-1
  92.     end if
  93.   end repeat
  94.   return (cnum)
  95. end findclosest
  96.  
  97.  
  98. on lockondates
  99.   set closest = findclosest()
  100.   set p1 = the loch of sprite (10+closest)+64
  101.   if p1>320 then
  102.     set tdist = p1-320
  103.     set tmpdist = tdist
  104.     repeat while tmpdist<>0
  105.       set scrollval = tmpdist/5
  106.       if scrollval<1 then
  107.         set scrollval =1
  108.       end if
  109.       displaydates -scrollval
  110.       set tmpdist = tmpdist-scrollval
  111.     end repeat
  112.   else if p1<320 then
  113.     set tdist = 320-p1
  114.     set tmpdist = tdist
  115.     repeat while tmpdist<>0
  116.       set scrollval = tmpdist/5
  117.       if scrollval<1 then
  118.         set scrollval =1
  119.       end if
  120.       displaydates scrollval
  121.       set tmpdist = tmpdist-scrollval
  122.     end repeat
  123.   else
  124.     autoclick
  125.   end if
  126.   set closest = findclosest()
  127.   set lasthl = datecast+closest
  128.   set the forecolor of member lasthl = 5
  129.   updatestage
  130. end lockondates
  131.  
  132. on autoclick
  133.   set tclickpt = the clickloc
  134.   set tclick = getat(tclickpt,1)
  135.   if tclick>512 then
  136.     set scdir = -2
  137.   else if tclick>384 then
  138.     set scdir = -1
  139.   else if tclick<128 then
  140.     set scdir = 2
  141.   else if tclick<256 then
  142.     set scdir = 1
  143.   end if
  144.   if movepossauto(scdir) then
  145.     set tdist = 128
  146.     set tmpdist = tdist
  147.     repeat while tmpdist<>0
  148.       set scrollval = tmpdist/5
  149.       if scrollval<1 then
  150.         set scrollval =1
  151.       end if
  152.       displaydates scrollval*scdir
  153.       set tmpdist = tmpdist-scrollval
  154.     end repeat
  155.     set closest = findclosest()
  156.     set lasthl = datecast+closest
  157.     set the forecolor of member lasthl = 5
  158.     updatestage
  159.   end if
  160. end autoclick
  161.  
  162. on movepossauto dir
  163.   if cdvar then
  164.     if dir>0 then
  165.       if (current-bigskip)-((dir-1)*bigskip)>=currentmin then
  166.         return (1)
  167.       else
  168.         return (0)
  169.       end if
  170.     else if dir<0 then
  171.       if ((current+bigskip)+((abs(dir)-1)*bigskip))<=currentmax then
  172.         return (1)
  173.       else
  174.         return (0)
  175.       end if
  176.     end if
  177.   else
  178.     if (current-(dir-1)>currentmin and dir>0) or¨
  179. (current+(abs(dir)-1)<currentmax and dir<0) then
  180.       return (1)
  181.     else
  182.       return (0)
  183.     end if
  184.   end if
  185. end movepossauto
  186.  
  187. on moveposs dir
  188.   if cdvar then
  189.     if dir>0 then
  190.       if current-bigskip>currentmin then
  191.         return (1)
  192.       else
  193.         return (0)
  194.       end if
  195.     else if dir<0 then
  196.       if current+bigskip<currentmax then
  197.         return (1)
  198.       else
  199.         return (0)
  200.       end if
  201.     end if
  202.   else
  203.     if (current>currentmin and dir>0) or (current<currentmax and dir<0) then
  204.       return (1)
  205.     else
  206.       return (0)
  207.     end if
  208.   end if
  209. end moveposs
  210.  
  211.  
  212. on displaydates factor
  213.   if factor <0 then
  214.     if the loch of sprite (fsprite+1+getat(spriteorder,1))<=-126 then
  215.       set the loch of sprite (fsprite+1+getat(spriteorder,1)) = ¨
  216. the loch of sprite (fsprite+1+getat(spriteorder,1))+640+128
  217.       switchorder 1
  218.     end if
  219.   else if factor >0 then
  220.     if the loch of sprite (fsprite+1+getat(spriteorder,6))>=640 then
  221.       set the loch of sprite (fsprite+1+getat(spriteorder,6)) = ¨
  222. the loch of sprite (fsprite+1+getat(spriteorder,6))-640-128
  223.       switchorder 0
  224.     end if
  225.   end if
  226.   repeat with j = 1 to 6
  227.     set spriteloch = the loch of sprite (fsprite+1+getat(spriteorder,j))
  228.     set spriteloch = spriteloch+factor
  229.     set the loch of sprite (fsprite+1+getat(spriteorder,j)) = spriteloch
  230.   end repeat
  231.   mywait 1
  232.   updatestage
  233. end displaydates
  234.  
  235. on switchorder right
  236.   if right then
  237.     set tmp = getat (spriteorder,1)
  238.     repeat with j = 1 to 5
  239.       setat spriteorder,j,getat(spriteorder,j+1)
  240.     end repeat
  241.     setat spriteorder,6,tmp
  242.     if cdvar then
  243.       set current = current+bigskip
  244.       set the text of cast (datecast+getat(spriteorder,6)) = ¨
  245. finddate(mygetat(keydates,current+(3*bigskip)))
  246.     else
  247.       set current = current+1
  248.       set the text of cast (datecast+getat(spriteorder,6)) = ¨
  249. finddate(mygetat(keydates,current+3))
  250.     end if
  251.   else
  252.     set tmp = getat (spriteorder,6)
  253.     repeat with j = 6 down to 2
  254.       setat spriteorder,j,getat(spriteorder,j-1)
  255.     end repeat
  256.     setat spriteorder,1,tmp
  257.     if cdvar then
  258.       set current = current-bigskip
  259.       set the text of cast (datecast+getat(spriteorder,1)) = ¨
  260. finddate(mygetat(keydates,current-(2*bigskip)))
  261.     else
  262.       set current = current-1
  263.       set the text of cast (datecast+getat(spriteorder,1)) = ¨
  264. finddate(mygetat(keydates,current-2))
  265.     end if
  266.   end if
  267. end switchorder
  268.  
  269. on mygetat var,pos
  270.   if pos<currentmin or pos>currentmax then
  271.     return (0)
  272.   else
  273.     return (getat(var,pos))
  274.   end if
  275. end mygetat
  276.